package com.nstar.base.effects
{
	import mx.effects.effectClasses.TweenEffectInstance;
	import mx.effects.Tween;

	/**
	 * 将背景色高亮的特效
	 * 
	 * @author 李嘉陵
	 * @date 2007.3.2
	 */
	public class HighLightInstance extends TweenEffectInstance
	{
		//public var beginColor:uint ;
		//public var endColor:uint ;
		
		private var red0:int;
		private var green0:int;
		private var blue0:int;
		
		private var red1:int;
		private var green1:int;
		private var blue1:int;
		
		private var current:uint;
		
 		public function set beginColor(value:uint):void {
			
			var str:String = value.toString(16);

			red0 = parseInt(str.substring(0,2),16);
			green0 = parseInt(str.substring(2,4),16);
			blue0 = parseInt(str.substring(4,6),16);
			
		}
		
		public function set endColor(value:uint):void {
			var str:String = value.toString(16);
			
			red1 = parseInt(str.substring(0,2),16);
			green1 = parseInt(str.substring(2,4),16);
			blue1 = parseInt(str.substring(4,6),16);
			
		}
		
		public function HighLightInstance(targetObj:*) {
            super(targetObj);
        }
  
        // Override play() method class.
        override public function play():void {
            // All classes must call super.play().
            super.play();
            // Create a Tween object. The tween begins playing immediately.
            var tween:Tween = 
                createTween(this, 
					[ red0, green0, blue0 ], 
					[ red1, green1, blue1 ], duration);  
        }

        // Override onTweenUpdate() method.
        override public function onTweenUpdate(val:Object):void {
        	val[0] = int(val[0]);
        	val[1] = int(val[1]);
        	val[2] = int(val[2]);
 	
        	var currentColor:uint = val[0] * 65536 + val[1] * 256 + val[2];
        	
            target.setStyle("backgroundColor",currentColor);
        }
  
        // Override onTweenEnd() method.
        override public function onTweenEnd(val:Object):void {
            // All classes that implement onTweenEnd() 
            // must call    super.onTweenEnd().
            super.onTweenEnd(val);
        }

	}
}